﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for MonthCardBLL
/// </summary>
public class MonthCardBLL:IMonthCardBLL
{
    //inject DAL
    private IMonthCardDAL monthCardDAL = Factory<IMonthCardDAL>.CreateInstance();
	public MonthCardBLL()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    #region IMonthCardBLL Members

    public List<MonthCard> GetAll()
    {
        return monthCardDAL.GetAll();
    }

    public MonthCard GetById(Guid id)
    {
        return monthCardDAL.GetById(id);
    }

    public bool IsExistedPlateNumber(string plateNumber, Guid id)
    {
        return monthCardDAL.IsExistedPlateNumber(plateNumber, id);
    }

    public bool Insert(MonthCard monthCard)
    {
        return monthCardDAL.Insert(monthCard);
    }

    public bool Update(MonthCard monthCard)
    {
        return monthCardDAL.Update(monthCard);
    }

    public bool Renew(MonthCard monthCard, Guid newID)
    {
        return monthCardDAL.Renew(monthCard, newID);
    }

    public bool Delete(Guid id)
    {
        return monthCardDAL.Delete(id);
    }

    public List<MonthCard> Search(MonthCard monthCard)
    {
        return monthCardDAL.Search(monthCard);
    }

    /// <summary>
    /// ActiveAction
    /// </summary>
    /// <param name="emp">Employee</param>
    /// <returns>bool</returns>
    public bool ActiveAction(MonthCard month)
    {
        try
        {
            //switch active
            if (month.Active)
                month.Active = false;
            else
                month.Active = true;

            return monthCardDAL.ActiveAction(month);
        }
        catch (Exception)
        {
            throw;
        }
    }

    #endregion
}
